home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / siod / siod_v29.lha / siod.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-16  |  5.4 KB  |  227 lines

  1. /* Scheme In One Defun, but in C this time.
  2.  
  3.  *                   COPYRIGHT (c) 1988-1992 BY                             *
  4.  *        PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS.       *
  5.  *        See the source file SLIB.C for more information.                  *
  6.  
  7. */
  8.  
  9. struct obj
  10. {short gc_mark;
  11.  short type;
  12.  union {struct {struct obj * car;
  13.         struct obj * cdr;} cons;
  14.     struct {double data;} flonum;
  15.     struct {char *pname;
  16.         struct obj * vcell;} symbol;
  17.     struct {char *name;
  18.         struct obj * (*f)(void);} subr0;
  19.     struct {char *name;
  20.         struct obj * (*f)(void *,...);} subr;
  21.     struct {struct obj *env;
  22.         struct obj *code;} closure;
  23.     struct {long dim;
  24.         long *data;} long_array;
  25.     struct {long dim;
  26.         double *data;} double_array;
  27.     struct {long dim;
  28.         char *data;} string;
  29.     struct {long dim;
  30.         struct obj **data;} lisp_array;
  31.     struct {FILE *f;
  32.         char *name;} c_file;}
  33.  storage_as;};
  34.  
  35. #define CAR(x) ((*x).storage_as.cons.car)
  36. #define CDR(x) ((*x).storage_as.cons.cdr)
  37. #define PNAME(x) ((*x).storage_as.symbol.pname)
  38. #define VCELL(x) ((*x).storage_as.symbol.vcell)
  39. #define SUBR0(x) (*((*x).storage_as.subr0.f))
  40. #define SUBRF(x) (*((*x).storage_as.subr.f))
  41. #define FLONM(x) ((*x).storage_as.flonum.data)
  42.  
  43. #define NIL ((struct obj *) 0)
  44. #define EQ(x,y) ((x) == (y))
  45. #define NEQ(x,y) ((x) != (y))
  46. #define NULLP(x) EQ(x,NIL)
  47. #define NNULLP(x) NEQ(x,NIL)
  48.  
  49. #define TYPE(x) (((x) == NIL) ? 0 : ((*(x)).type))
  50.  
  51. #define TYPEP(x,y) (TYPE(x) == (y))
  52. #define NTYPEP(x,y) (TYPE(x) != (y))
  53.  
  54. #define tc_nil    0
  55. #define tc_cons   1
  56. #define tc_flonum 2
  57. #define tc_symbol 3
  58. #define tc_subr_0 4
  59. #define tc_subr_1 5
  60. #define tc_subr_2 6
  61. #define tc_subr_3 7
  62. #define tc_lsubr  8
  63. #define tc_fsubr  9
  64. #define tc_msubr  10
  65. #define tc_closure 11
  66. #define tc_free_cell 12
  67. #define tc_string       13
  68. #define tc_double_array 14
  69. #define tc_long_array   15
  70. #define tc_lisp_array   16
  71. #define tc_c_file       17
  72. #define tc_user_1 50
  73. #define tc_user_2 51
  74. #define tc_user_3 52
  75. #define tc_user_4 53
  76. #define tc_user_5 54
  77.  
  78. #define tc_sys_1 91
  79. #define tc_sys_2 92
  80. #define tc_sys_3 93
  81. #define tc_sys_4 94
  82. #define tc_sys_5 95
  83.  
  84.  
  85. #define FO_fetch 127
  86. #define FO_store 126
  87. #define FO_list  125
  88. #define FO_listd 124
  89.  
  90. #define tc_table_dim 100
  91.  
  92. typedef struct obj* LISP;
  93.  
  94. #define CONSP(x)   TYPEP(x,tc_cons)
  95. #define FLONUMP(x) TYPEP(x,tc_flonum)
  96. #define SYMBOLP(x) TYPEP(x,tc_symbol)
  97.  
  98. #define NCONSP(x)   NTYPEP(x,tc_cons)
  99. #define NFLONUMP(x) NTYPEP(x,tc_flonum)
  100. #define NSYMBOLP(x) NTYPEP(x,tc_symbol)
  101.  
  102. #define TKBUFFERN 256
  103.  
  104. struct gen_readio
  105. {int (*getc_fcn)(char *);
  106.  void (*ungetc_fcn)(int, char *);
  107.  char *cb_argument;};
  108.  
  109. #define GETC_FCN(x) (*((*x).getc_fcn))((*x).cb_argument)
  110. #define UNGETC_FCN(c,x) (*((*x).ungetc_fcn))(c,(*x).cb_argument)
  111.  
  112. void process_cla(int argc,char **argv,int warnflag);
  113. void print_welcome(void);
  114. void print_hs_1(void);
  115. void print_hs_2(void);
  116. long no_interrupt(long n);
  117. LISP get_eof_val(void);
  118. void repl_driver(long want_sigint,long want_init);
  119. void set_repl_hooks(void (*puts_f)(),
  120.             LISP (*read_f)(),
  121.             LISP (*eval_f)(),
  122.             void (*print_f)());
  123. void repl(void) ;
  124. void err(char *message, LISP x);
  125. char *get_c_string(LISP x);
  126. long get_c_long(LISP x);
  127. LISP lerr(LISP message, LISP x);
  128.  
  129. LISP newcell(long type);
  130. LISP cons(LISP x,LISP y);
  131. LISP consp(LISP x);
  132. LISP car(LISP x);
  133. LISP cdr(LISP x);
  134. LISP setcar(LISP cell, LISP value);
  135. LISP setcdr(LISP cell, LISP value);
  136. LISP flocons(double x);
  137. LISP numberp(LISP x);
  138. LISP plus(LISP x,LISP y);
  139. LISP ltimes(LISP x,LISP y);
  140. LISP difference(LISP x,LISP y);
  141. LISP quotient(LISP x,LISP y);
  142. LISP greaterp(LISP x,LISP y);
  143. LISP lessp(LISP x,LISP y);
  144. LISP eq(LISP x,LISP y);
  145. LISP eql(LISP x,LISP y);
  146. LISP symcons(char *pname,LISP vcell);
  147. LISP symbolp(LISP x);
  148. LISP symbol_boundp(LISP x,LISP env);
  149. LISP symbol_value(LISP x,LISP env);
  150. LISP cintern(char *name);
  151. LISP rintern(char *name);
  152. LISP subrcons(long type, char *name, LISP (*f)());
  153. LISP closure(LISP env,LISP code);
  154. void gc_protect(LISP *location);
  155. void gc_protect_n(LISP *location,long n);
  156. void gc_protect_sym(LISP *location,char *st);
  157.  
  158. void init_storage(void);
  159.  
  160. void init_subr(char *name, long type, LISP (*fcn)());
  161. LISP assq(LISP x,LISP alist);
  162. LISP delq(LISP elem,LISP l);
  163. void set_gc_hooks(long type,
  164.           LISP (*rel)(),
  165.           LISP (*mark)(),
  166.           void (*scan)(),
  167.           void (*free)(),
  168.           long *kind);
  169. LISP gc_relocate(LISP x);
  170. LISP user_gc(LISP args);
  171. LISP gc_status(LISP args);
  172. void set_eval_hooks(long type,LISP (*fcn)());
  173. LISP leval(LISP x,LISP env);
  174. LISP symbolconc(LISP args);
  175. void set_print_hooks(long type,void (*fcn)());
  176. LISP lprin1f(LISP exp,FILE *f);
  177. LISP lprint(LISP exp);
  178. LISP lread(void);
  179. LISP lreadtk(long j);
  180. LISP lreadf(FILE *f);
  181. void set_read_hooks(char *all_set,char *end_set,
  182.             LISP (*fcn1)(),LISP (*fcn2)());
  183. LISP oblistfn(void);
  184. LISP vload(char *fname,long cflag);
  185. LISP load(LISP fname,LISP cflag);
  186. LISP save_forms(LISP fname,LISP forms,LISP how);
  187. LISP quit(void);
  188. LISP nullp(LISP x);
  189. void init_subrs();
  190. LISP strcons(long length,char *data);
  191. LISP read_from_string(LISP x);
  192. LISP aref1(LISP a,LISP i);
  193. LISP aset1(LISP a,LISP i,LISP v);
  194. LISP cons_array(LISP dim,LISP kind);
  195. LISP string_append(LISP args);
  196. LISP string_length(LISP string);
  197.  
  198. void init_subrs(void);
  199.  
  200. LISP copy_list(LISP);
  201.  
  202.  
  203. long c_sxhash(LISP,long);
  204. LISP sxhash(LISP,LISP);
  205.  
  206. LISP href(LISP,LISP);
  207. LISP hset(LISP,LISP,LISP);
  208.  
  209. LISP fast_print(LISP,LISP);
  210. LISP fast_read(LISP);
  211.  
  212. LISP equal(LISP,LISP);
  213.  
  214. LISP assoc(LISP x,LISP alist);
  215.  
  216. LISP make_list(LISP x,LISP v);
  217.  
  218. void set_fatal_exit_hook(void (*fcn)(void));
  219.  
  220. LISP parse_number(LISP x);
  221.  
  222. LISP intern(LISP x);
  223.  
  224.  
  225. void init_trace(void);
  226.  
  227.